<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<!-- AUTHOR: Dakota -->
<html xmlns="http://www.w3.org/1999/xhtml"   
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      >
    <body>
        <ui:composition>
            <h:form>
                <p:tabView>
                    <p:tab title="Assign" >
                        <p:outputPanel>
                            <p:remoteCommand name="updateAssign" update="@form"/>

                            <!-- EXERCISE ASSIGNMENT PANEL -->
                            <h:panelGrid id="assignGrid" columns="3">
                                <h:outputText value="These are the exercises you have assigned to your students. You may choose to remove them from the list below: " />
                                <h:outputText value="Select exercises from the system pool to assign to your students:" />
                                <h:outputText value="Select exercises from the custom exercise list to assign to your students:" />

                                <h:selectManyListbox id="assigned" size = "10" value="#{assignBean.assignedItems}">
                                    <f:selectItems value="#{assignBean.assignedValue}"/>
                                </h:selectManyListbox>
                                <h:selectManyListbox id="default" size = "10" value="#{assignBean.defaultExerciseItems}">
                                    <f:selectItems value="#{assignBean.defaultExerciseValue}"/>
                                </h:selectManyListbox>
                                <h:selectManyListbox id="custom" size = "10" value="#{assignBean.customItems}">
                                    <f:selectItems value="#{assignBean.customValue}"/>
                                </h:selectManyListbox>

                                <p:commandButton value="Remove from Assigned Exercise" process="@form" update=":tabForm:growl" oncomplete="updateAssign();" action="#{assignBean.removeAssigned}" />
                                <p:commandButton value="Add to Assigned List" process="@form" update=":tabForm:growl" oncomplete="updateAssign();" action="#{assignBean.assignDefaultExercises}" />
                                <p:commandButton value="Add to Assigned List" />
                            </h:panelGrid>
                            <!-- TIME ZONE PANEL -->
                            <h:panelGrid id="timeGrid" columns="4" cellpadding="10" >
                                <h:outputText value="Your current time zone is set to #{assignBean.timeZoneId}" />
                                <h:outputText style="font-weight:bold" value="Choose a new time zone" />
                                <h:selectOneMenu value="#{assignBean.selectedTimezone}">  
                                    <f:selectItems value="#{assignBean.timezones}" var="t" itemLabel="#{t}" itemValue="#{t}"/>
                                    <f:selectItem itemLabel="ACT" itemValue="ACT" />
                                </h:selectOneMenu>  
                                <p:commandButton value="Set&nbsp;a&nbsp;new&nbsp;time&nbsp;zone" process="@form" update=":tabForm:growl timeGrid" action="#{assignBean.setTimezone}"/>
                            </h:panelGrid>
                            <!-- EXERCISE INFO PANEL -->
                            <p:fieldset legend="Assigned Exercises"> 
                                <h:panelGrid columns="2" >
                                    <h:outputText value="Note: After the due date, students will not be able to submit the exercise. By default, the due date is set to a week from the current date and the score is set to 10. You can change the due date and score in the table and click Save Changes to save the change. If you have set values for an individual, the individual settings are independent from the values set in the following table." style="width:70%" />
                                    <p:commandButton value="Save" process="@form" update=":tabForm:growl" oncomplete="updateAssign();" action="#{assignBean.updateAssigned}" />
                                </h:panelGrid>
                                <p:dataTable id="assignTable" value="#{assignBean.assignedTableList}" var="exercise">
                                    <p:column headerText="Exercise Name">
                                        <h:outputText value="#{exercise.exerciseName}" />
                                    </p:column>
                                    <p:column headerText="Assigned">
                                        <h:outputText value="#{exercise.whenCreated}" />
                                    </p:column>
                                    <p:column headerText="Due Date">
                                        <p:inputText value="#{exercise.dueDate}" style="width:80%"/>
                                    </p:column>
                                    <p:column headerText="Score">
                                        <p:inputText value="#{exercise.score}"  />
                                    </p:column>
                                </p:dataTable>
                            </p:fieldset>  
                        </p:outputPanel>
                    </p:tab>
                    <p:tab title="Examine">

                    </p:tab>
                </p:tabView>
            </h:form>
        </ui:composition>
    </body>
</html>
